<template>
  <el-container direction="vertical">
    <el-main>
      <h1 style="text-align: left;margin-top: 40px;margin-bottom: 30px" class="bi-search"> 搜索结果</h1>
<!--      <p style="margin-bottom: 40px">☕️总有你想要的☕️</p>-->
      <div class="row justify-content-start feature">
        <div class="col-sm-6 col-md-5 col-lg-3" v-for="(items,index) in results" :key="index">
          <Good :item=results[index]></Good>
        </div>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import axios from "axios";
import Good from "@/components/Good";
export default {
  name: "Search",
  components:{Good},
  data(){
    return{
      results:[]
    }
  },
  created() {
    var search = this.$route.query.search;
    axios.get('http://r44734h518.zicp.vip:41569/goods/getAllGoods').then(res=>{
      for (var i=0;i<res.data.length;i++){
        if (res.data[i].gname.match(search)) {
          this.results.push(res.data[i]);
        }
      }
    })
  }
}
</script>

<style scoped>

</style>
